//
//  ANOptionTableViewSub.m
//  Ants
//
//  Created by ZHM on 16/7/11.
//  Copyright © 2016年 ZHM. All rights reserved.
//

#import "ANOptionTableViewSub.h"
#import "ANOptionsTableViewController.h"
@interface ANOptionTableViewSub ()
@property (nonatomic, assign) CGRect rect;


@end



@implementation ANOptionTableViewSub

// 显示弹出菜单
+ (instancetype)optionTableViewWithRect:(CGRect)rect toView: (UIView *) toView{
    CGRect hideFrame = rect;
    hideFrame.origin.x = toView.frame.size.width;
    
    ANOptionTableViewSub *view = [[ANOptionTableViewSub alloc] initWithFrame:hideFrame];
    view.userInteractionEnabled = YES;
    view.backgroundColor = CitysBackgroundColor;
    
    [toView addSubview:view];
    view.rect = rect;
    return view;
}
- (void)showOptionView {
    //动画
    [UIView animateWithDuration:ANFindToolAnimationTime animations:^{
        self.transform = CGAffineTransformMakeTranslation(-_rect.size.width,0);
    }];
}
// 隐藏弹出菜单
- (void)hideOptionViewAnimation:(BOOL)animation
{
    if (animation) {
        [UIView animateWithDuration:ANFindToolAnimationTime animations:^{
            self.transform = CGAffineTransformIdentity;
        }];
    } else {
        self.transform = CGAffineTransformIdentity;
    }
}

// 设置内容视图
- (void)setContentView:(UIView *)contentView
{
    _contentView = contentView;
    contentView.backgroundColor = [UIColor clearColor];
    [self addSubview:contentView];
}
- (void)layoutSubviews
{
    [super layoutSubviews];
    CGFloat w = self.width;
    CGFloat h = self.height;
    _contentView.frame = CGRectMake(0, 0, w, h);
    
}
@end
